<?php
	include "../database.php";

	$story_id = $_GET["story_id"];
	$sprint_id = $_GET["sprint_id"];
	
	$queryTime = "SELECT story_time FROM story WHERE story_id='$story_id'";
	$queryTimeResult = executeQuery($queryTime);
	while ($row = mysql_fetch_array($queryTimeResult)){
		$time = $row[0];
	}
	$success = 0;
	
	if($sprint_id == ""){
		$msg = message(111);
		$data = array('msg' => "$msg", 'success' => $success);
		echo json_encode($data);	
	}
	else if ($time != null){ 
		$query = "UPDATE story SET story_sprint = '$sprint_id' WHERE story_id = '$story_id'";
		executeQuery($query);
		$success = 1;
		$data = array('success' => $success);
		echo json_encode($data);
		
	} else {
		$msg = message(110);
		$data = array('msg' => "$msg", 'success' => $success);
		echo json_encode($data);
	}
	
?>
